﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Computer_Manager.DAL;
using Computer_Manager.DTO;
using DevExpress.XtraEditors;
using System.Windows.Forms;

namespace Computer_Manager.BUS
{
    class BUS_order
    {
        DAL_order dal = new DAL_order();

        public int order_insert(DTO_order obj)
        {
            int id = 0;
            try
            {
                id =  dal.order_insert(obj);
            }
            catch (Exception e)
            {

                XtraMessageBox.Show(e.Message, "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                
            }
            return id;
            
        }

        public void order_Update(DTO_order obj)
        {
            try
            {
                dal.order_Update(obj);
            }
            catch (Exception e)
            {

                XtraMessageBox.Show(e.Message, "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        public void order_Delete(DTO_order obj)
        {
            try
            {
                dal.order_Delete(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public DataTable GetByID(DTO_order obj)
        {
            DataTable dt = new DataTable();
            try
            {
                dt = dal.GetByID(obj);
            }
            catch (Exception e)
            {
                XtraMessageBox.Show(e.Message, "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //throw;
            }
            return dt;
        }

        public DataTable GetByIdCus(DTO_order obj)
        {
            DataTable dt = new DataTable();
            try
            {
                dt = dal.GetByIdCus(obj);
            }
            catch (Exception)
            {

                throw;
            }
            return dt;
        }

        public DataTable GetByDay(DTO_order obj)
        {
            DataTable dt = new DataTable();
            try
            {
                dt = dal.GetByDay(obj);
            }
            catch (Exception)
            {

                throw;
            }
            return dt;
        }

        public DataTable GetByMonth(DTO_order obj)
        {
            DataTable dt = new DataTable();
            try
            {
                dt = dal.GetByMonth(obj);
            }
            catch (Exception)
            {

                throw;
            }
            return dt;
        }

        public DataTable GetByYear(DTO_order obj)
        {
            DataTable dt = new DataTable();
            try
            {
                dt = dal.GetByYear(obj);
            }
            catch (Exception)
            {

                throw;
            }
            return dt;
        }

        public DataTable GetAll()
        {
            DataTable dt = new DataTable();
            try
            {
                dt = dal.GetAll();

            }
            catch (Exception)
            {

                throw;
            }
            return dt;
        }
    }
}
